<template>
  <el-main>

    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          prop="orderId"
          label="订单Id"
          width="180">
      </el-table-column>
      <el-table-column
          prop="userId"
          label="用户id"
          width="180">
      </el-table-column>
      <el-table-column
          prop="orderAmount"
          label="金额"
          width="180">
      </el-table-column>
      <el-table-column
          prop="orderTime"
          label="下单时间"
          width="180">
      </el-table-column>
      <el-table-column
          prop="status"
          label="订单状态"
          width="180">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="toPay(scope.row)">支付</el-button>
          <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)">退款</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-main>





</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      tableData: [],
    }
  },
  methods:{
    toPay(order) {
      location.href = this.axios.defaults.baseURL + "/order/order/pay?id=" + order.orderId;
      /*this.axios.get('/order/order/pay',{params:{id: order.orderId}}).then(res=>{

      })*/

    },
    page(){
      this.axios.get('/order/order/page').then(res=>{
        this.tableData = res.data.data.list;
      })
    }
  },
  created() {
    this.page();

    let query = this.$route.query;
    console.log(query);

    if (query.out_trade_no) {
      this.axios.post('/order/order/callback',query).then(res=>{
        this.$router.push("/order");
        this.page();
      });
    }

  }
}
</script>

<style scoped>
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both
}
</style>